#include <iostream>
#include <cstring>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
		string a;
		int b;
		cin>>a>>b;
		int len=a.length() ;
		a[b-1]='#';
		for(int i=0;i<len;i++){
			if(a[i]=='#') continue;
			cout<<a[i];
		}
		cout<<endl;
	}
}
